const express=require('express')
const mysql=require('mysql')
const fs=require('fs')
const server=express()
server.listen(8888,()=>{
    console.log('my server id running')
})
const pool=mysql.createPool({
    host:'127.0.0.1',
    port:'3306',
    user: 'root',
    password: '',
    database:'soupu'
})
let cate=[ "简谱","电子琴谱","笛萧谱", "二胡谱","钢琴谱","古筝谱", "合唱谱","吉他谱","其他谱","萨克斯谱","手风琴谱","总谱"]

let arr=[
    {
        "comment": "唱响建党百年主题歌曲！",
        "photo": "comment/20211231092714493.jpg"
    },
    {
        "comment": "经典老歌味道浓。",
        "photo": "comment/20220104132913777.jpg"
    },
    {
        "comment": "西部情歌就是这个味道。",
        "photo": "comment/20220102113800699002.jpg"
    },
    {
        "comment": "我们声乐班教材有这首歌曲，过来比对一下简谱。",
        "photo": "comment/20210328174534422.jpg"
    },
    {
        "comment": "歌唱解放军战士，安全和平的保卫",
        "photo": "comment/20220102074854288.gif"
    },
    {
        "comment": "弟子规，亮人生。",
        "photo": "comment/20090619131011759.gif"
    },
    {
        "comment": "人生的主要阶段就是红星照我去战斗",
        "photo": "comment/20210313231538812.jpg"
    },
    {
        "comment": "唱响新世纪，奔向中国梦！",
        "photo": "comment/20220102113111697.jpg"
    },
    {
        "comment": "起身小号吹响啦！",
        "photo": "comment/20210821191600732.gif"
    },
    {
        "comment": "丽江发生5•5级地震。",
        "photo": "comment/20220102112839403002.jpg"
    },
    {
        "comment": "没有填词。",
        "photo": "comment/20210727182639914.png"
    }
]


// 封装插入函数
function insert(sql,key){
    pool.query(sql,key,(err,res)=>{
        if(err) throw err
        // console.log(res)
    })
}

let sql='INSERT INTO jipu ( comment,photo ) VALUES (?,?);'
arr.forEach((el)=>{
    let key=[el['comment'],el['photo']]
    insert(sql,key)
})